package com.sf.message.conf;
import com.sf.message.service.CurrencyMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
 * Description:
 * Date: 2018-07-08
 * Time: 16:25
 * @author purui_zhang
 */
@Configuration
@ConditionalOnClass(CurrencyMessageService.class)
@EnableConfigurationProperties(MessageServiceProperties.class)
public class MessageAutoConfigure {

    @Autowired
    private MessageServiceProperties properties;

    @Bean
    @ConditionalOnMissingBean
    @ConditionalOnProperty(prefix = "com.sf.message.service",value = "enabled",havingValue = "true")
    CurrencyMessageService messageService (){
        return  new CurrencyMessageService(properties.getProduct(),properties.getDomain(),properties.getAccessKeyId(),properties.getAccessKeySecret(),properties.getSignName(),properties.getTemplateCode(),properties.getInitialCapacity(),properties.getConcurrencyLevel(),properties.getExpire(),properties.getJpushAppKey(),properties.getJpushMasterSecret(),properties.getAccountName(),properties.getFromAlias());
    }

}
